﻿<%@ WebHandler Language="C#" Class="favorite" %>

using System;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using Chenxin.Lib.Utility;

public class favorite : AjaxHandlerBase
{
    
    //*******************************************
    //功能概要       ：重写的请求处理方法
    //参数説明       ：context 请求的上下文
    //返回值説明     ：无
    //功能詳細       ：父类中隐藏了IHttpHandler接口方法，本类中须对本方法进行重写
    //作成者         ：姚志强
    //作成日         ：2010-03-04 
    //修改者         ：王玮
    //修改日         ：2010-03-25
    //*******************************************
    override public void RequestProcess(HttpContext context)
    {
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";
        
        string strOp = context.Request["op"];
        string strResponse = "";
        switch (strOp.ToLower())
        {
            case "add":
                strResponse = AddFavorsInfo(context);
                break;
            case "getlist":
                //strResponse = GetFavorList(context);
                strResponse = GetList(context);
                break;
            case "del":
                strResponse = DelFavorsInfo(context);
                break;
            default:
                break;
        }
        context.Response.Write(strResponse);
    }

    private string GetList(HttpContext context)
    {
        try
        {

            int strType = (string.IsNullOrEmpty(context.Request["FavorType"])) ? 0 : int.Parse(context.Request["FavorType"]);
            string strKeyword = context.Request["keyword"];
            //string strOrderField = context.Request["orderfield"];
            //string strOrderField = " FavorId";
            int iPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
            int iPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数
            string strTable = string.Empty;
            string fieldlist = string.Empty;
            string tablefieldlist = string.Empty;
            string sort = string.Empty;
            string strSort = context.Request["sort"].ToString();
            
            System.Text.StringBuilder sb = new StringBuilder();
            sb.Append(" Status<>-10");
            sb.AppendFormat(" and (A.FavorPersonId = '{0}')", CurrentUserInfo.UserId);

            string head = "";
            switch (context.Request["showtype"].ToString())
            {
                //主营业务
                case "10":
                    head = "columns.houseFavorHead";
                    strType = 0;
                    break;
                case "20":
                    head = "columns.customerFavorHead";
                    strType = 1;
                    break;
                default:
                    break;
            }
            
            sb.AppendFormat(" AND (A.FavorType = {0})", strType);
            switch (strType)
            {
                case 0:
                    strTable = "Personal_FavorsInfo A left join House_BaseInfo B on  B.HouseId = A.FavorId";
                    fieldlist = "favorname as Community ,*";
                    tablefieldlist = "favorname as Community ,*";
                    if (!string.IsNullOrEmpty(strKeyword))
                    {
                        sb.AppendFormat(" AND ((B.Address like '%{0}%') OR (A.FavorName LIKE '%{0}%'))", strKeyword);
                    }
                    if (!string.IsNullOrEmpty(strSort))
                    {
                        if ((strSort == "Community desc") || (strSort == "BuildingArea desc") || (strSort == "Model_Room desc") || (strSort == "SalePrice_T desc") || (strSort == "SalePrice_U desc") || (strSort == "RentPrice desc") || (strSort == "Region desc") || (strSort == "Address desc") || (strSort == "Status desc") || (strSort == "OprDepart desc") || (strSort == "OprPerson desc") || (strSort == "AddTime desc"))
                        {
                            if (strSort == "Community desc")
                            {
                                sort = " favorname desc";
                            }
                            else
                            {
                                sort = " " + strSort;
                            }
                        }
                        else if ((strSort == "Community asc") || (strSort == "BuildingArea asc") || (strSort == "Model_Room asc") || (strSort == "SalePrice_T asc") || (strSort == "SalePrice_U asc") || (strSort == "RentPrice asc") || (strSort == "Region asc") || (strSort == "Address asc") || (strSort == "Status asc") || (strSort == "OprDepart asc") || (strSort == "OprPerson asc") || (strSort == "AddTime asc"))
                        {
                            if (strSort == "Community asc")
                            {
                                sort = " favorname asc";
                            }
                            else
                            {
                                sort = " " + strSort;
                            }
                        }
                        else
                        {
                            sort = " A.AddTime DESC ";
                        }
                    }
                    else
                    {
                        sort = " A.AddTime DESC ";
                    }
                    break;
                case 1:
                    strTable = "Personal_FavorsInfo A left join Customer_BaseInfo B on  B.CustomerId = A.FavorId";
                    fieldlist = "favorname as Customer ,*";
                    tablefieldlist = "favorname as Customer ,*";
                    if (!string.IsNullOrEmpty(strKeyword))
                    {
                        sb.AppendFormat(" AND ((B.CustomerCode like '%{0}%') OR (A.FavorName LIKE '%{0}%'))", strKeyword);
                    }
                    sort = " A.AddTime DESC ";
                    if (context.Request["sort"] != null && context.Request["sort"] != "")
                    {
                        sort = " " + context.Request["sort"];
                    }
                    if (!string.IsNullOrEmpty(strSort))
                    {
                        if (strSort == "Customer desc" || strSort == "CustomerCode desc" || strSort == "Mobile desc" || strSort == "Phone desc" || strSort == "CertificateType desc" || strSort == "CertificateNo desc" || strSort == "OprDepart desc" || strSort == "OprPerson desc")
                        {
                            sort = " " + strSort;
                        }
                        else
                        {
                            sort = " A.AddTime DESC ";
                        }
                    }
                    else
                    {
                        sort = " A.AddTime DESC ";
                    }
                    break;
            }
            
            System.Data.DataSet dslist = null;
            //string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + "."+strType.ToString());
            //Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            //dslist = cs.GetDataSet(strCachKey);
            
            dslist = Chenxin.Lib.House.DAL.Personal_FavorsInfo.GetList(
                    iPageIndex, iPageSize, sort.ToString(), strTable, sb.ToString(), fieldlist, tablefieldlist, true);

            int count = (int)dslist.Tables[1].Rows[0][0];

            //string strHtml = "";
            //if (!GetKeyListHtml(strType, dslist, out strHtml))
            //{
            //    return string.Format("{{success:'0',msg:'{0}',data:''}}", "生成HTML错误:" + strHtml);
            //}
            //dslist.Dispose();
            //dslist = null;
            //return string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',html:'{2}'}}}}", "成功", count, strHtml);
            
            return string.Format("{{success:1,msg:'',data:{{count:{0},head:{1},{2}}}}}", count, head, JsonHelp.Convert2Json(dslist.Tables[0]));
        }
        catch (Exception e)
        {
            return "{success:0,msg:'获取列表失败！" + e.Message + "',data:''}";
        }
    }


    //*******************************************
    //功能概要       ：收藏房源
    //参数説明       ：
    //返回值説明     ：
    //功能詳細       ：收藏房源
    //作成者         ：姚志强
    //作成日         ：2010-03-03
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string AddFavorsInfo(HttpContext context)
    {
        try
        {
            string houseId = context.Request.Params["houseid"];
            string houseAddress = context.Request.Params["houseaddress"];
            string favorType = context.Request.Params["favortype"];
            if (houseId == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源标识丢失，请联系管理员！");
            if (Chenxin.Lib.House.BLL.House_BaseInfo.ValidateIsExistFavors(houseId,CurrentUserInfo.UserId.ToString()))
            {
                return string.Format("{{success:'1',msg:'{0}',data:''}}", "已添加到收藏中！");
            }
            else
            {   //添加收藏
                  //创建收藏实体对象
                Chenxin.Lib.House.Entity.Personal_FavorsInfo model = new Chenxin.Lib.House.Entity.Personal_FavorsInfo();
                model.RecordId = Guid.NewGuid();
                model.FavorId = new Guid(houseId);
                model.FavorName = houseAddress;
                if (!string.IsNullOrEmpty(favorType))
                {
                    model.FavorType = Convert.ToInt16(favorType);
                }
                else
                {
                    model.FavorType = 0;
                }
                model.FavorPersonId = CurrentUserInfo.UserId;
                model.FavorPerson = CurrentUserInfo.UserName;
                model.AddTime = DateTime.Now;
                Chenxin.Lib.House.BLL.House_BaseInfo.AddFavorsInfo(model);
                //删除缓存
                string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + ".1000");
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                cs.Delete(strCachKey);
                strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + ".1");
                cs.Delete(strCachKey);
                strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + ".0");
                cs.Delete(strCachKey);

                //添加用户操作日志 2010-5-11 王玮 Add
                AddLog("" + CurrentUserInfo.UserName + "添加了一个收藏:[" + model.FavorName + "]已添加收藏",
                        OperationType.OperationTypeComboList()["OprType_CollectionAdd"].ToString());
                
            }
            
            return string.Format("{{success:'1',msg:'{0}',data:''}}", "收藏成功！");
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }

    }

    //*******************************************
    //功能概要       ：删除收藏房源
    //参数説明       ：
    //返回值説明     ：
    //功能詳細       ：删除收藏房源
    //作成者         ： 
    //作成日         ：2010-03-03
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string DelFavorsInfo(HttpContext context)
    {
        try
        {
            string favorId = context.Request.Params["modelid"];
            if (string.IsNullOrEmpty(favorId))
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "收藏标识丢失，请联系管理员！");

            Chenxin.Lib.House.Entity.Personal_FavorsInfo clhepf = Chenxin.Lib.House.DAL.Personal_FavorsInfo.GetModel(new Guid(favorId));

            Chenxin.Lib.House.DAL.Personal_FavorsInfo.Delete(new Guid(favorId));
            //删除缓存

            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + ".1000");
            cs.Delete(strCachKey);
            strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + ".1");
            cs.Delete(strCachKey);
            strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + ".0");
            cs.Delete(strCachKey);

            //添加用户操作日志 2010-5-11 王玮 Add
            AddLog("" + CurrentUserInfo.UserName + "删除了一个收藏:[" + clhepf.FavorName + "]已删除收藏",
                    OperationType.OperationTypeComboList()["OprType_CollectionDel"].ToString());

            return string.Format("{{success:'1',msg:'{0}',data:''}}", "移出成功！");
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }

    /// <summary>
    /// 返回列表；
    /// 根据查询参数生成查询条件1,根据权限设定生成查询条件2；
    /// 返回Json数据：{count:'30',data:'abc'}
    /// </summary>
    /// <param name="context"></param>
    private bool GetKeyListHtml(int strType,System.Data.DataSet dslist, out string strHtml)
    {
        try
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<table width=\"100%\" height=\"100%\" cellspacing=\"1\" class=\"tabsorternew\" id=\"report\">");
            sb.Append("<thead><tr>");
            
            switch(strType)
            {
                case 0:
                    sb.Append("<th width=\"8%\">房源地址</th>");
                    sb.Append("<th width=\"8%\">面积</th>");
                    sb.Append("<th width=\"5%\" >房型</th>");
                    sb.Append("<th width=\"8%\" >总价</th>");
                    sb.Append("<th width=\"7%\">单价</th>");
                    sb.Append("<th width=\"8%\">租价</th>");
                    sb.Append("<th width=\"10%\">区域</th>");
                    sb.Append("<th width=\"10%\">地址</th>");
                    sb.Append("<th width=\"5%\">状态</th>");
                    sb.Append("<th width=\"15%\">部门</th>");
                    sb.Append("<th width=\"8%\">业务员</th>");
                    sb.Append("<th width=\"8%\">收藏时间</th>");
                    sb.Append("</tr></thead><tbody>");
                    foreach (System.Data.DataRow row in dslist.Tables[0].Rows)
                    {
                        sb.AppendFormat("<dl id=\"{0}\">", row["RecordId"].ToString());
                        sb.AppendFormat("<dd>{0}</dd>", string.Format("<a name=\"{0}\" class=\"a_show\" href=\"#\">\"{1}\"</a>", row["RecordId"].ToString(), Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Community", "")));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "BuildingArea", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Model_Room", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_T", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_U", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "RentPrice", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Region", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Address", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Status", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprDepart", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprPerson", ""));
                        sb.AppendFormat("<dd>{0:yyyy-MM-dd}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "AddTime", ""));
                        sb.Append("</dl>");
                    }
                    break;
                case 1:
                    sb.Append("<th width=\"8%\">客户姓名</th>");
                    sb.Append("<th width=\"8%\">编号</th>");
                    sb.Append("<th width=\"5%\" >手机号码</th>");
                    sb.Append("<th width=\"8%\" >电话号码</th>");
                    sb.Append("<th width=\"7%\">证件类型</th>");
                    sb.Append("<th width=\"8%\">证件号码</th>");
                    sb.Append("<th width=\"10%\">区域</th>");
                    sb.Append("<th width=\"10%\">地址</th>");
                    sb.Append("<th width=\"5%\">状态</th>");
                    sb.Append("<th width=\"15%\">部门</th>");
                    sb.Append("<th width=\"8%\">业务员</th>");
                    sb.Append("<th width=\"8%\">收藏时间</th>");
                    sb.Append("</tr></thead><tbody>");
                    foreach (System.Data.DataRow row in dslist.Tables[0].Rows)
                    {
                        sb.AppendFormat("<dl id=\"{0}\">", row["RecordId"].ToString());
                        sb.AppendFormat("<dd>{0}</dd>", string.Format("<a name=\"{0}\" class=\"a_show\" href=\"#\">\"{1}\"</a>", row["RecordId"].ToString(), Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Customer", "")));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CustomerCode", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Mobile", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Phone", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CertificateType", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CertificateNo", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Region", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Address", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Status", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprDepart", ""));
                        sb.AppendFormat("<dd>{0}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprPerson", ""));
                        sb.AppendFormat("<dd>{0:yyyy-MM-dd}</dd>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "AddTime", ""));
                        sb.Append("</dl>");
                    }
                    break;
            }
            strHtml = sb.ToString();
            return true;
        }
        catch (Exception ex)
        {
            strHtml = ex.Message;
            return false;
        }
    }

    ///// <summary>
    ///// 获取收藏列表
    ///// </summary>
    ///// <param name="context"></param>
    ///// <returns></returns>
    //private string GetFavorList(HttpContext context)
    //{
    //    int strType = (string.IsNullOrEmpty(context.Request["FavorType"])) ? 1000 : int.Parse(context.Request["FavorType"]);
    //    string strKeyword = context.Request["keyword"];
    //    string strOrderField = context.Request["orderfield"];
    //    int iPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1:int.Parse(context.Request["pageindex"]) +1;//页码
    //    int iPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30:int.Parse(context.Request["pagesize"]);//页记录数

    //    System.Text.StringBuilder sb = new StringBuilder();
    //    sb.AppendFormat("(A.FavorPersonId = '{0}')", CurrentUserInfo.UserId);
    //    if (strType != 1000) sb.AppendFormat(" AND (A.FavorType = {0})", strType);
    //    if (!string.IsNullOrEmpty(strKeyword)) sb.AppendFormat(" AND (A.FavorName LIKE '%{0}%')", strKeyword);
        
    //    StringBuilder sbOrder = new StringBuilder();
    //    if (string.IsNullOrEmpty(strOrderField)) sbOrder.Append(" A.AddTime DESC ");
        
    //    System.Data.DataSet dslist = null;
    //    //string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_MYFAVOR, CurrentUserInfo.UserId.ToString() + "."+strType.ToString());
    //    //Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
    //    //dslist = cs.GetDataSet(strCachKey);

    //    string fieldlist = "*";
    //    string tablefieldlist = "*";

    //    dslist = Chenxin.Lib.House.DAL.Personal_FavorsInfo.GetList(
    //            iPageIndex, iPageSize, sbOrder.ToString(), "Personal_FavorsInfo A left join House_BaseInfo B on  B.HouseId = A.FavorId", sb.ToString(), fieldlist, tablefieldlist, true);
        
    //    int count = (int)dslist.Tables[1].Rows[0][0];

    //    string strHtml = "";
    //    if (!GetFavorListHtml(dslist, out strHtml))
    //    {
    //        return string.Format("{{success:'0',msg:'{0}',data:''}}", "生成HTML错误");
    //    }

    //    dslist.Dispose();
    //    dslist = null;
    //    return string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',data:'{2}'}}}}", "成功", count, strHtml);
    //}

    //private bool GetFavorListHtml(System.Data.DataSet dslist, out string strHtml)
    //{
    //    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    //    sb.Append("<table width=\"100%\" height=\"100%\" cellspacing=\"1\" class=\"tabsorternew\" id=\"report\">");
    //    sb.Append("<thead>");
    //    sb.Append("<tr><th width=\"30\" >操作</th>");
    //    sb.Append("<th width=\"40\">区域</th>");
    //    sb.Append("<th width=\"140\">房源地址/客户姓名</th>");
    //    sb.Append("<th width=\"30\" >面积</th>");
    //    sb.Append("<th width=\"90\" >房型</th>");
    //    sb.Append("<th width=\"60\" >总价</th>");
    //    sb.Append("<th width=\"60\" >单价</th>");
    //    sb.Append("<th width=\"60\" >租价</th>");
    //    sb.Append("<th width=\"40\" >状态</th>");
    //    sb.Append("<th width=\"70\" >部门</th>");
    //    sb.Append("<th>业务员</th>");
    //    sb.Append("</tr></thead>");
    //    sb.Append("<tbody>");

    //    int i = 0;
    //    foreach (System.Data.DataRow row in dslist.Tables[0].Rows)
    //    {
    //        if (i % 2 == 0)
    //            sb.AppendFormat("<tr id=\"{0}\" class=\"tr_favorlist\">", row["RecordId"].ToString());
    //        else
    //            sb.AppendFormat("<tr id=\"{0}\" class=\"tr_houselist bluebgcolor\">", row["RecordId"].ToString());
                
    //        //操作列
    //        sb.AppendFormat("<td>{0}</td>", string.Format("<a name=\"{0}\" href=\"javascript:void(0)\" class=\"a_favor_remove\">移除</a>",row["RecordId"].ToString()));
    //        //区域
    //        sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Region", ""));
            
    //        //房源地址/客户姓名
    //        sb.AppendFormat("<td>{0}</td>",
    //            Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "FavorType",0) == 0 ?
    //            string.Format("<a name=\"{1}\" class=\"a_favor_house\" href=\"ShowDetailInfo.aspx?houseid={1}\" target=\"blank\">{0}</a>", row["FavorName"].ToString(), row["FavorId"]) :
    //            string.Format("<a name=\"{1}\" class=\"a_favor_customer\" href=\"javascript:void(0)\">{0}</a>", row["FavorName"].ToString(), row["FavorId"]));

    //        //面积
    //        sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "BuildingArea", "0"));
    //        //房型
    //        string room = string.Empty;
    //        string hall = string.Empty;
    //        string toilet = string.Empty;
    //        string balcony = string.Empty;
    //        if (row["Model_Room"] != null && !string.IsNullOrEmpty(row["Model_Room"].ToString()))
    //            room = row["Model_Room"].ToString() + "室";
    //        if (row["Model_Hall"] != null && !string.IsNullOrEmpty(row["Model_Hall"].ToString()))
    //            hall = row["Model_Hall"].ToString() + "厅";
    //        if (row["Model_Toilet"] != null && !string.IsNullOrEmpty(row["Model_Toilet"].ToString()))
    //            toilet = row["Model_Toilet"].ToString()+"卫";
    //        if (row["Model_Balcony"] != null && !string.IsNullOrEmpty(row["Model_Balcony"].ToString()))
    //            balcony = row["Model_Balcony"].ToString() + "阳台";
    //        string model = room + hall + toilet + balcony;
    //        sb.AppendFormat("<td>{0}</td>",  model);
    //        //总价
    //        sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_T", 0));
    //        //单价
    //        sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "SalePrice_U", 0));
    //        //租价
    //        sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "RentPrice", 0));
    //        //状态
    //        string tempStat = string.Empty;
    //        if (row["Status"] != null && !string.IsNullOrEmpty(row["Status"].ToString()))
    //        {
                
    //            int stat = Convert.ToInt32(row["Status"]);
    //            if(stat==10)
    //                tempStat = "有效";
    //            if(stat==-1)
    //                 tempStat = "无效";
    //            if(stat==20)
    //                 tempStat = "暂缓";
    //            if(stat==30)
    //                 tempStat = "封盘";
    //        }
    //        sb.AppendFormat("<td>{0}</td>", tempStat);
    //        //部门
    //        sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprDepart", ""));
    //        //业务员
    //        sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprPerson", ""));
    //        //类型
    //        //sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "FavorType", 0) == 0 ? "房源" : "客源");
    //        //收藏时间
    //        //sb.AppendFormat("<td>{0:yyyy-MM-dd}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "AddTime", DateTime.Today));

    //        sb.Append("</tr>");
    //        i++;
    //    }

    //    sb.Append("</tbody></table>");

    //    strHtml = sb.ToString();
    //    return true;
    //}
}